package com.pms.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import com.pms.entity.Ideacomment;
import com.pms.util.DBHelp;
import com.pms.util.RowMapper;

public class IdeacommentDao {
	
	
	DBHelp<Ideacomment> db=new DBHelp<Ideacomment>();
	public void save(String id,String content,String t_idea_id,String t_user_id,String createtime){
	String sql="insert into t_ideacomment(id,content,t_idea_id,t_user_id,createtime) value(?,?,?,?,?)";
		db.executeSQL(sql, id,content,t_idea_id,t_user_id,createtime);
	
	}
	public List<Ideacomment> findById(String t_idea_id){
		String sql="select id,content,t_idea_id,t_user_id,createtime from t_ideacomment where t_idea_id = ?";
		return db.executeQueryForList(sql, new IdeacommentRowMapper(), t_idea_id);
	}
	

	  class IdeacommentRowMapper implements RowMapper<Ideacomment> {

			public Ideacomment mapperRow(ResultSet rs) throws SQLException {
				Ideacomment idea = new Ideacomment();
				idea.setId(rs.getString("id"));
				idea.setContent(rs.getString("content"));
				idea.setCreatetime(rs.getString("createtime"));
				idea.setT_user_id(rs.getString("t_user_id"));
				idea.setT_idea_id(rs.getString("t_idea_id"));
				//UserDao name=new UserDao();
				//idea.setUser(name.findById(rs.getString("t_user_id")));
				return idea;
			}
			}
	  }